l_v = []
l_w = []
l_vpw = []
def proccess(a):
    return a[1:-1].split(',')

def split(a):
    l_a = list(a)
    k = len(l_a)
    for i in range(1,len(l_a)):
        if l_a[i] == ',' and l_a[i - 1] == ')':
            l_a.remove(l_a[i])
            k = len(l_a)
    return l_a
    
def listtostr(l_a):
    a = ''
    for i in l_a:
        a += i
        
    return a
        
    
def inp():
    w = int(input())
    n = int(input())
    a = input()
    aa = a
    print(split(aa))
    aa = listtostr(split(aa))
    for i in aa:
        print(i)
        l_v.append(int(proccess(i)[0]))
        l_w.append(int(proccess(i)[1]))
    return w,l_v,l_w


def vperw(l_v,l_w,l_vpw):
    for v,w in l_v,l_w:
        l_vpw.append((v,w,v/w))
        
def sort(l_vpw):
    l_vpw.sort()

def put(l_vpw,w,money):
    ll_vpw
    k = min(l_vpw[0][1],w)
    ww = w
    ww -= k
    money += k * l_vpw[0][2]
    return money
    
def calmoney(l_vpw,w,money):
    while w > 0 and len(l_vpw) != 0:
        put(l_vpw,w,money)
        return money
    
def main(l_v,l_w,l_vpw):
    l_v,l_w,l_pvw = inp()
    vperw(l_v,l_w,l_vpw)
    sort(l_vpw)
    print(calmoney(l_vpw,w,put(l_vpw,w,0)))
        
        
main(l_v,l_w,l_vpw)